/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

/**
 *
 * @author spider391Tang
 */
import java.net.*;
import java.io.*;
import java.util.*;

class obj extends ChatFormat implements BroadcastMsg {

    public obj(String line) {
        
        super(line);
        String[] names = line.split(" ");
        cmd = names[0].substring(1);
        if (names.length > 1) {
            msg = names[1];
        } else {
            /// 公子乖 -　回報錯誤
            msg = "";
        }
        msg+="-";
        msg+=KKMultiServerThread.wb_msg_id;
        KKMultiServerThread.wb_msg_id++;
        //System.out.println(msg);
        for (int i = 2; i < names.length; i++) {
            msg = msg.concat(" " + names[i]);
        }
        
    }

    public void sendMsg(PrintWriter out, KKMultiServerThread server) {
        String name = server.getUser();
        server.send_obj_client(out, msg);

    }

    public void execute(KKMultiServerThread server) {

        String[] names = msg.split(" ");
        server.getWbMsgQueue().put(names[0], msg.substring(names[0].length()+1));
        server.broadcast(this);
    }
}
